package XML.T1;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.File;
import java.util.List;

public class T1 {

    public static void main(String[] args) throws DocumentException {

        SAXReader sr = new SAXReader();
        Document doc = sr.read(new File("city.xml"));
        Element rootElement = doc.getRootElement();
        List<Element> elements = rootElement.elements();
        for (Element element : elements) {
            String id = element.attributeValue("id");
            System.out.println("cityid："+id);
            List<Element> proEle = element.elements();
            for (Element pro : proEle) {
                System.out.println(pro.getName()+"："+pro.getText());
            }
            System.out.println("------------");
        }

    }
}